package com.woniuxy.educationplatform.mapper;

import com.woniuxy.educationplatform.bean.*;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Mapper
public interface OptionMapper {
    /**
     * 查询所有选项
     * @return
     */
    @Results({
            @Result(id = true, property = "id", column = "id", javaType = Long.class),
            @Result(property = "optContent", column = "opt_content", javaType = String.class),
            @Result(property = "isRight", column = "is_right", javaType = Boolean.class),

            @Result(property = "testBean", column = "fk_test_infoid", javaType = TestBean.class, one =
           @One(select = "com.woniuxy.educationplatform.mapper.TestMapper.getOneById", fetchType = FetchType.LAZY)),

           @Result(property = "quesBean", column = "fk_question_infoid", javaType = QuesBean.class, one =
           @One(select = "com.woniuxy.educationplatform.mapper.QuesMapper.getOneById", fetchType = FetchType.LAZY))

    })
    @Select("select * from option_info")
    List<OptionBean> findAll();



    @Insert(value = "INSERT INTO option_info (opt_content, is_right, fk_test_infoid, fk_question_infoid) VALUES (#{optContent}, #{isRight}, #{testBean.id}, #{quesBean.id})")
    void insert(OptionBean optionBean);








}
